package base.jfinal;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import org.apache.log4j.Logger;

/**
 * Created by Administrator on 2016-5-27.
 */
public class HandlerError implements Interceptor {
    private Logger log=Logger.getLogger(getClass());
    @Override
    public void intercept(Invocation inv) {
        try {
            inv.invoke();
        }catch (Exception ex){
            log.error("出错了:"+ex.getMessage());
            inv.getController().renderJson("{\"err\":-500}");
            inv.getController().getResponse().setStatus(200);
            ex.printStackTrace();
        }
    }
}
